# —*— coding: utf-8 -*-

import sys
import logging
from logging import Handler

from flask import Flask, Request, Response

app = Flask(__name__)

app.env = 'development'
app.debug = True

root_logger = logging.getLogger()
console_handler = logging.StreamHandler(stream=sys.stdout)
console_formatter = '%(asctime)s %(process)d %(thread)d {%(pathname)s:%(lineno)d} (%(funcName)s) - %(message)s'
console_handler.setFormatter(fmt=logging.Formatter(console_formatter))
root_logger.addHandler(console_handler)
root_logger.setLevel(logging.DEBUG)

flask_logger = logging.getLogger('flask.app')

@app.route('/')
def index():
    root_logger.info('root index')
    flask_logger.info('flask index')
    return 'OK'


# 启动服务：进程阻塞，后面代码不会执行
app.run(host='0.0.0.0', port=8000, threaded=False, processes=2)
